/*
 * @author: huangww
 * @Date: 2021-02-22 14:51:12
 * @LastEditTime: 2021-02-24 16:49:06
 * @FilePath: \fmgr\src\core\mgr\MSGMgr.ts
 * 网络请求
 */
namespace core {
    export class MSGMgr {
        private socket: Socket;
        private static instance: MSGMgr;
        constructor() {
            this.socket = new Socket;
            this.initEvent();
        }
        initEvent() {
            EventMgr.getInstance().addEvent(EventKey.NET_CONNECT, () => {

            }, this);
            EventMgr.getInstance().addEvent(EventKey.NET_DISCONNECT, () => {

            }, this);
        }

        connect(url: string) {
            this.socket.connect(url);
        }

        sendSocket(msg: Msg) {
            this.socket.send(msg);
        }

        sendHttp(url, params, msg: Msg) {
            HTTPApi.send(url, params, msg);
        }





        static getInstance() {
            if (!this.instance) {
                this.instance = new MSGMgr();
            }
            return this.instance;
        }
    }
}